#include<stdio.h>
#include<stdlib.h>
#include<math.h>

double calculatePolygonArea(int numCorners, double x[], double y[]){
double ar=0;
for(int i=1; i <=numCorners; i++){
	ar += ((x[i]+x[i-1])*(y[i]-y[i-1])); 
	
}return fabs(ar/2.0);
}

int main (){
int n, i=0;
printf("Enter number of distict corners for the polygon: ");
scanf("%d",&n);

if(n < 3){
	printf("Error");
return 1;
}	
double ar, x[n+1], y[n+1];
for (; i<n ; i++){
	printf("Enter the x and y coordonates of corner#%d: ",i+1);
	scanf("%lf %lf", &x[i], &y[i]);
	
} 	
	x[n]= x[0];
	y[n]= y[0];
	ar= calculatePolygonArea (n, x, y);
	printf("Pplygon area = %lf sqr meters\n", ar);
	
	return 0; 
	
}


